package com.me.web;

import com.me.pojo.Pokemon;
import com.me.pojo.Trainer;
import com.me.service.PokemonService;
import com.me.service.TrainerService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/trainerallServlet")
public class trainerallServlet extends HttpServlet {

        //1.调用PokemonService获取所有Pokemon
        TrainerService service = new TrainerService();
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

            List<Trainer> trainers= service.selectall();
            //2.将Pokemon放入request
            request.setAttribute("trainers",trainers);
            //3.转发到pokemon.jsp
            request.getRequestDispatcher("trainermg.jsp").forward(request,response);

        }

        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            this.doGet(request, response);
        }
    }

